package org.zsl.mybatis.mapper;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;
import org.apache.ibatis.type.JdbcType;
import org.zsl.mybatis.model.Order;

import java.util.List;


public interface OrderMapper {


    @Select("select * from `order` where order_id = #{orderId}")
    @Results(id = "orderMapper",value = {
            @Result(column = "order_id",property = "orderId"
                    ,jdbcType = JdbcType.INTEGER,id = true),
            @Result(column = "order_id",property = "items"
                    ,many = @Many(select = "org.zsl.mybatis.mapper.ItemMapper.selectByOrderId"
                    ,fetchType = FetchType.LAZY))
    })
    Order selectById(Integer orderId);


    /**
     * 学生自行实现
     * */
    List<Order> selectAll();
}
